package com.sancai.fruit.presenter;

import android.util.Log;

import com.sancai.fruit.base.BasePresenterIm;
import com.sancai.fruit.bean.Movie;
import com.sancai.fruit.contract.MianActivityContract;
import com.sancai.fruit.model.MianActivityModel;
import com.sancai.fruit.utils.NerWorkUtilss;

/**
 * Created by xiangyao on 2018/8/2.
 */

public class MianActivityPresenter extends BasePresenterIm<MianActivityContract.View> implements MianActivityContract.Presenter {

    MianActivityModel mianActivityModel;

    public MianActivityPresenter() {
        mianActivityModel = new MianActivityModel();
    }

    @Override
    public void getData(String start, String count) {
        mView.showLoadingView();
        if (!NerWorkUtilss.isNetWorkAvailable(mContext)) {
            mView.showNetErrorView();
            return;
        }
        addSubscription(mianActivityModel.findMovies(start, count).subscribe(movie -> {
            mView.showDataSuccess(new Movie());
            mView.showContentView();
        }, throwable -> {
            mView.showDataError(throwable.getMessage());
            mView.showContentView();
        }));


    }
}
